package cn.sdxx.qddata.entity;


import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDate;

// shiro 的session 要求User序列化
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "用户id")
    //解决返回给前端后，js中Long 数据 精度丢失问题，因为js中long最大支持2的53次方
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @ApiModelProperty(value = "用户名")
    private String username;

    //本想忽略返回密码字段，但是连提交json数据，也忽略了提交的密码字段
//    @JsonIgnore
//    @NotNull(groups = {SysUser.AddUser.class},message = "用户密码不能为空")
//    @Size(groups = {SysUser.AddUser.class,SysUser.UpdateUser.class},min = 3, max = 11, message = "密码长度必须是3-16个字符")
    @ApiModelProperty(value = "密码")
    //改为更灵活的@JsonProperty
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String password;

    @ApiModelProperty(value = "昵称")
    private String nickname;

    @ApiModelProperty(value = "生日")
    private LocalDate birthday;

    @ApiModelProperty(value = "手机号")
    private Long phone;

    @ApiModelProperty(value = "职业")
    private String occupation;

    @ApiModelProperty(value = "地址")
    private String address;

    @ApiModelProperty(value = "公司")
    private String company;

    @ApiModelProperty(value = "email")
    private String email;

    @ApiModelProperty(value = "头像（路径）")
    private String avatar;


}
